package com.zgjkhis.modules.system.rest;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zgjkhis.logging.aop.log.Log;
import com.zgjkhis.modules.security.security.LoginUserUtil;
import com.zgjkhis.modules.system.domain.Label;
import com.zgjkhis.modules.system.service.LabelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @date 2018-11-23
 */
@Api(tags = "标签管理：标签管理")
@RestController
@RequestMapping("/label")
public class LabelController {

    private static final String ENTITY_NAME = "label";
    private final LabelService labelService;

    public LabelController(LabelService labelService) {
        this.labelService = labelService;
    }


    @Log("查询标签")
    @ApiOperation("查询标签")
    @GetMapping(value = "/getLabels")
//    @PreAuthorize("@el.check('drug:list')")
    public ResponseEntity<Object> getLabels(){
        List<Label> list=labelService.list(Wrappers.<Label>query().lambda().eq(Label::getPharmacyId,LoginUserUtil.getPharmId()).eq(Label::getStatus,0));
        return new ResponseEntity<>(list,HttpStatus.OK);
    }

}
